clear

// Get the path of the currently running do-file
local do_file_path `c(pwd)'

// Change the working directory to the location of the do-file
cd "`do_file_path'"

import dbase using "local\gis_data\003_boundaries\fishnet_pt0.dbf", clear

rename POINT_X lon
rename POINT_Y lat
rename *, lower
rename joinid objectid


drop join_count closest target_fid
drop nl_name_1 nl_name_2
drop gid_0-lat

sum objectid

** labels
label variable objectid "Seq id per grid or split grid at country border"

label variable bh3ss "Boko-Haram 3 state - dummy state level"
label variable bhbs "Boko-Haram borno - dummy state level"
label variable bhbrs "Boko-Haram between rivers - dummy state level"

label variable bh3sd "Boko-Haram 3 state - dummy district level"
label variable bhbd "Boko-Haram borno - dummy district level"
label variable bhbrd "Boko-Haram between rivers - dummy district level"

label variable bh3sc "Boko-Haram 3 state - dummy commune level"
label variable bhbc "Boko-Haram borno - dummy commune level"
label variable bhbrc "Boko-Haram between rivers - dummy commune level"

label variable neibh3ss1 "1st neighbouring state of BH 3 states"
label variable neibh3ss2 "2nd neighbouring state of BH 3 states"
label variable neibh3ss3 "3rd neighbouring state of BH 3 states"
label variable neibh3ss4 "4th neighbouring state of BH 3 states"
label variable neibh3ss5 "5th neighbouring state of BH 3 states"

label variable neibh3sd1 "1st neighbouring district of BH 3 states"
label variable neibh3sd2 "2nd neighbouring district of BH 3 states"
label variable neibh3sd3 "3rd neighbouring district of BH 3 states"
label variable neibh3sd4 "4th neighbouring district of BH 3 states"
label variable neibh3sd5 "5th neighbouring district of BH 3 states"

label variable neibh3sc1 "1st neighbouring commune of BH 3 states"
label variable neibh3sc2 "2nd neighbouring commune of BH 3 states"
label variable neibh3sc3 "3rd neighbouring commune of BH 3 states"
label variable neibh3sc4 "4th neighbouring commune of BH 3 states"
label variable neibh3sc5 "5th neighbouring commune of BH 3 states"

label variable neibhbs1 "1st neighbouring state of BH borno"
label variable neibhbs2 "2nd neighbouring state of BH borno"
label variable neibhbs3 "3rd neighbouring state of BH borno"
label variable neibhbs4 "4th neighbouring state of BH borno"
label variable neibhbs5 "5th neighbouring state of BH borno"

label variable neibhbd1 "1st neighbouring district of BH borno"
label variable neibhbd2 "2nd neighbouring district of BH borno"
label variable neibhbd3 "3rd neighbouring district of BH borno"
label variable neibhbd4 "4th neighbouring district of BH borno"
label variable neibhbd5 "5th neighbouring district of BH borno"

label variable neibhbc1 "1st neighbouring commune of BH borno"
label variable neibhbc2 "2nd neighbouring commune of BH borno"
label variable neibhbc3 "3rd neighbouring commune of BH borno"
label variable neibhbc4 "4th neighbouring commune of BH borno"
label variable neibhbc5 "5th neighbouring commune of BH borno"


label variable neibhbrs1 "1st neighbouring state of BH between rivers"
label variable neibhbrs2 "2nd neighbouring state of BH between rivers"
label variable neibhbrs3 "3rd neighbouring state of BH between rivers"
label variable neibhbrs4 "4th neighbouring state of BH between rivers"
label variable neibhbrs5 "5th neighbouring state of BH between rivers"

label variable neibhbrd1 "1st neighbouring district of BH between rivers"
label variable neibhbrd2 "2nd neighbouring district of BH between rivers"
label variable neibhbrd3 "3rd neighbouring district of BH between rivers"
label variable neibhbrd4 "4th neighbouring district of BH between rivers"
label variable neibhbrd5 "5th neighbouring district of BH between rivers"

label variable neibhbrc1 "1st neighbouring commune of BH between rivers"
label variable neibhbrc2 "2nd neighbouring commune of BH between rivers"
label variable neibhbrc3 "3rd neighbouring commune of BH between rivers"
label variable neibhbrc4 "4th neighbouring commune of BH between rivers"
label variable neibhbrc5 "5th neighbouring commune of BH between rivers"

sort objectid

save "proc_data\TREAT.dta", replace
